<script src="{{ getAssets }}js/amazeui.datatables.min.js?v={{ assets_version }}"></script>
<script>
var typeid = {
    '1':'采购入库',
    '2':'冲红出库',
    '3':'退货出库',
    '4':'报损出库',
    '5':'盘盈入库',
    '6':'盘亏出库',
    '7':'销售出库',
    '8':'销退入库',
    '9':'调拨出库',
    '10':'调拨入库',
    '11':'调拨退回',
};
$('a[data-typeid="10"]').addClass("am-btn-primary");
var queryParams = {};
var tables = $('#dataTables').DataTable({
    "sAjaxSource" : '{{ urlfor "InventoryController.Flowing"}}'
    ,"bLengthChange": false
    ,"fnServerData" : function(sSource, aoData, fnCallback) {
        queryParams = checkQueryTableData(aoData);
        var form = $('.query-form').serializeArray();
        $.each(form, function(i, value){
            queryParams[value.name] = value.value;
        });
        $.post(sSource, JSON.stringify(queryParams),function(resp) {
            fnCallback(resp);
        },'json')
    }
    ,columns: [
        {render:function(data, type, full, meta) {
            return full.Products.BrandName;
        }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
            return full.Products.Name;
        }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Snd.sph;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Snd.cyl;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Snd.add;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Snd.model;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Snd.color;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Snd.size;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Snd.function_info;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Acceptance.lot_number;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Acceptance.Id!=0 ? timetransDate(full.Acceptance.manufacture_date) : '';
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Acceptance.Id!=0 ? timetransDate(full.Acceptance.expiry_date) : '';
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.PrimaryStorageNum;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.StorageNum;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return typeid[full.Typeid];
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return timetrans(full.CreatedAt);
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.PurchaseUpNo;
            }, "bSortable": false}
    ]
    ,"aLengthMenu":[20, 50, 100, 200]
	,'bLengthChange': true
    ,"serverSide": true
    ,"bPaginate" : true
    ,"bFilter" : false	//是否启动过滤、搜索功能
    ,"bInfo" : true //是否显示页脚信息，DataTables插件左下角显示记录数
    ,"bProcessing" : true //DataTables载入数据时，是否显示‘进度’提示
});

$("#query-submit").bind("click", function () { //点击按钮 触发table重新请求服务器
    $("#dataTables").dataTable().fnDraw(false);
    return false;
});

var typeid_option = '<option value=""></option>';
$.each(typeid, function(index, value){
    typeid_option += '<option value="'+index+'">'+ value +'</option>';
});
$('#typeid').html(typeid_option);

$.post('{{ urlfor "ProductsController.GetOptions"}}', {'fields':['goods_lens_genre', 'goods_lens_optical_design', 'goods_lens_refractivity', 'goods_function_info', 'goods_lens_material_quality']},  function(res){
    setattroption('genre',res.data.goods_lens_genre);
    setattroption('optical_design',res.data.goods_lens_optical_design);
    setattroption('refractivity',res.data.goods_lens_refractivity);
    setattroption('function_info',res.data.goods_function_info);
    setattroption('material_quality',res.data.goods_lens_material_quality);

});
</script>
{{template "./inventory/p.html" .}}